<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<c:set var="fatherId" value="0"/>
<c:choose>
	<c:when test="${param.id!=null}">
　	　<c:set var="fatherId" value="${param.id}"/>
　　</c:when>
</c:choose>
<c:choose>
	<c:when test="${param.fatherId!=null}">
　	　<c:set var="fatherId" value="${param.fatherId}"/>
　　</c:when>
</c:choose>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head> 
    <title>My JSP 'leibie_list.jsp' starting page</title>

  </head>
  
  <body>
    <table>
		<tr>
			<td>属性</td>
			<td colspan="2">操作</td>
		</tr>
		<tr>
			<td colspan="3">
			<form method="post" action="${webpath}/admin/product/product_leibie/ProductAtrribute.do?action=saveProductAtrribute">
				<table>
					<tr>
						<td><input type="text" value="" name="atrribute_name">
							<input type="hidden" value="${fatherId}" name="fatherId" id="fatherId" />
						</td>
						<td><input type="submit" value="添加类别" name="submit"></td>
					</tr>
				</table>
			</form>
			</td>
		</tr>
		<c:forEach var="leibie" items="${productAtrributeLiebei}">
		<tr>
			<td><label id="${leibie.id}"><a href="${webpath}/admin/product/product_leibie/ProductAtrribute.do?action=findProductAtrribute&fatherId=${leibie.id}">${leibie.atrribute_name}</a></label>
			<input type="text" value="${leibie.atrribute_name}" name="leibie${leibie.id}" id="leibie${leibie.id}" style="display:none" />
			</td>
			<td>
			<input name="leibie_edit${leibie.id}" id="leibie_edit${leibie.id}" type="button" onClick="displays('${leibie.id}')" value="修改">
			<input name="leibie_edit_submit${leibie.id}" id="leibie_edit_submit${leibie.id}" type="button" onClick="updateleibie('${leibie.id}')" value="保存" style="display:none"></td>
			<td><input name="leibie_del" type="button" onClick="window.location='${webpath}/admin/product/product_leibie/ProductAtrribute.do?action=deleteProductAtrribute&id=${leibie.id}&fatherId=${fatherId}'" value="删除"></td>
		</tr>
		</c:forEach>
	</table>
	<form method="post" action="${webpath}/admin/product/product_leibie/ProductAtrribute.do?action=updateProductAtrribute" id="updateleibieform">
		<input type="hidden" name="id" id="id" />
		<input type="hidden" name="atrribute_name" id="atrribute_name" />
		<input type="hidden" value="${fatherId}" name="fatherId" id="fatherId" />
	</form>
  </body>
  <script language="javascript">
	function displays(id)
	{
		var tempid=id;
		eval("document.getElementById('"+tempid+"').style.display='none'");
		eval("document.getElementById('leibie"+tempid+"').style.display=''");
		eval("document.getElementById('leibie_edit"+tempid+"').style.display='none'");
		eval("document.getElementById('leibie_edit_submit"+tempid+"').style.display=''");
	}
	function updateleibie(id)
	{
		var leibie=document.getElementById("leibie"+id).value;
		document.getElementById("updateleibieform").id.value=id;
		document.getElementById("updateleibieform").atrribute_name.value=leibie;
		document.getElementById("updateleibieform").submit();
	}
</script>
</html>
